package com.wlcorp.forcazamis.sys.permission;

import java.util.Map;

public class PermissionSub {
	private String id;
	private String title;
	private String type;
	private boolean isEnumerated;
	private String Desc;
	private Map<?, ?> values;
	private String parentId;

	public String getDesc() {
		return Desc;
	}
	public void setDesc(String desc) {
		Desc = desc;
	}
	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}
	public boolean isEnumerated() {
		return isEnumerated;
	}
	public void setEnumerated(boolean isEnumerated) {
		this.isEnumerated = isEnumerated;
	}
	public String getTitle() {
		return title;
	}
	public void setTitle(String title) {
		this.title = title;
	}
	public String getType() {
		return type;
	}
	public void setType(String type) {
		this.type = type;
	}
	public Map<?, ?> getValues() {
		return values;
	}
	public void setValues(Map<?, ?> values) {
		this.values = values;
	}

	public String getParentId() {
		return parentId;
	}
	public void setParentId(String parentId) {
		this.parentId = parentId;
	}

	public void addValue(String value){
		//非枚举型value数量不能大于1
		if(! isEnumerated && values.size() > 0){
			return;
		}
		PermissionMap paramMap = PermissionXMLBuilder.createPermissionMap();
		paramMap.addValue(value,id);
	}

	public void removeValue(String id){
		values.remove(values.get(id));
		PermissionMap paramMap = PermissionXMLBuilder.createPermissionMap();
		paramMap.removeParam(id);
	}

	public void updateValue(String id, String value){
		PermissionMap paramMap = PermissionXMLBuilder.createPermissionMap();
		paramMap.updateValue(id,value);
	}

        public String getValue(){
          return (String)values.get(PermissionXMLBuilder.PERMISSION_VALUE);
        }

}
